package com.ittable.tdcqfdmeo.serivice.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * @author srh
 * @date 2020/10/18
 **/
@Component
public class BeanFactoryUtils implements ApplicationContextAware {

    private ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    public Object getBean(String beanName) {
        return applicationContext.getBean(beanName);
    }

    public Object getBean(Class<?> beanClass) {
        return applicationContext.getBean(beanClass);
    }
}
